package pl.ydp.components.mathcell.mathrecognizer.geometry
{
	public class Tempz
	{
		public function Tempz()
		{
			/*
			for (var ref:Number = 0 ; ref < primitives.length ; ref ++){
				for (var test:Number = 0 ; test < primitives.length ; test ++){
					
					if (test == ref  ||  primitives[ref].type == PrimitiveType.LOOP  ||   
						primitives[ref].type == PrimitiveType.UNKNOWN  ||   primitives[test].type == PrimitiveType.UNKNOWN){
						continue;
					}
					
					doJoint = false;
					refProcessingBegin = false;
					testProcessingBegin = true;
					
					//  --- FIND GENERAL JOINT CAPACITY ---
					
					// CHECK TWO LINES
					
					if (PrimitiveType.isLine(primitives[ref].type)  &&  PrimitiveType.isLine(primitives[test].type)){
						
						if (!PrimitiveType.areOrthogonal(primitives[ref].type, primitives[test].type)  &&
							Angle.differenceAbs(primitives[ref].angle, primitives[test].angle) < Parameters.MAX_JOINT_LINE_ANGLE_DIFF  && 
							Point.distance(primitives[test].begin,primitives[ref].begin) > Point.distance(primitives[test].begin,primitives[ref].end)){
							doJoint = true;	
						}
						
					}
					
					// CHECK TWO CURVES
					
					if (PrimitiveType.isCurve(primitives[ref].type)  &&  PrimitiveType.isCurve(primitives[test].type)){
						
						if (Point.distance(primitives[test].begin,primitives[ref].begin) > Point.distance(primitives[test].begin,primitives[ref].end)){
							doJoint = true;
						}
						
					}
					
					
					// CHECK REF = CURVE, TEST + LINE
					
					if (PrimitiveType.isCurve(primitives[ref].type)  &&  PrimitiveType.isLine(primitives[test].type)){
						
						curveLineEndingsDistances.push( Point.distance(primitives[ref].begin, primitives[test].begin) );
						curveLineEndingsDistances.push( Point.distance(primitives[ref].begin, primitives[test].end) );
						curveLineEndingsDistances.push( Point.distance(primitives[ref].end, primitives[test].begin) );
						curveLineEndingsDistances.push( Point.distance(primitives[ref].end, primitives[test].end) );
						
						var minDistanceIndex:Number = Functions.findMinimumIndex(curveLineEndingsDistances);
						
						switch (minDistanceIndex){
							case (0):
							refProcessingBegin = true;
							testProcessingBegin = true;
							break;
							case (1):
							refProcessingBegin = true;
							testProcessingBegin = false;
							break;
							case (2):
							refProcessingBegin = false;
							testProcessingBegin = true;
							break;
							case (3):
							refProcessingBegin = false;
							testProcessingBegin = false;
							break;
						}
						
						if (refProcessingBegin){
							refAngle = primitives[ref].angleBegin;
						} else {
							refAngle = primitives[ref].angleEnd;	
						}
						testAngle = primitives[test].angle;
						
						if (Angle.differenceAbs(refAngle, testAngle) < Parameters.MAX_JOINT_LINE_ANGLE_DIFF){
							doJoint = true;
						}
						
					}
					
					if (!doJoint){
						continue;
					}
					
					if (testProcessingBegin){
						vStart = 0;
						vStop = primitives[test].vectors.length - 3;
						vStep = 1;
					} else {
						vStart = primitives[test].vectors.length - 3;
						vStop = 0;
						vStep = -1;
					}
						
					
					for (var v:Number = vStart ; v != vStop ; v += vStep){
					
						//var ad:Number = Angle.differenceDirectionAngleAbs(primitives[ref].angleEnd, primitives[test].vectors[v].angle);
						var angleDiff:Number = Angle.difference(primitives[ref].angleEnd, primitives[test].vectors[v].angle);
						var angleDiffAbs:Number = Angle.differenceAbs(primitives[ref].angleEnd, primitives[test].vectors[v].angle);
						var jd:Number = Point.distance(primitives[ref].end, primitives[test].vectors[v].point);
						
						if( 
							(
								(
									(PrimitiveType.isLine(primitives[ref].type)  ||  PrimitiveType.isLine(primitives[test].type))  
									&&
									Math.abs(angleDiff) < Parameters.MAX_JOINT_LINE_ANGLE_JOINT_DIFF
								) 
								||
								(	
									PrimitiveType.isCurve(primitives[ref].type)  &&  PrimitiveType.isCurve(primitives[test].type)  
									&&  
									Math.abs(angleDiff) < Parameters.MAX_JOINT_CURVE_ANGLE_JOINT_DIFF
									
								)
								||
								(	
									PrimitiveType.isCurve(primitives[ref].type)  &&  PrimitiveType.isLine(primitives[test].type)  
									&&  
									angleDiffAbs < Parameters.MAX_JOINT_CURVE_ANGLE_JOINT_DIFF
									
								)
							)  
							&&
							(
								(refProcessingBegin  &&  Point.distance(primitives[ref].begin, primitives[test].vectors[v].point) < Parameters.MAX_JOINT_DISTANCE)
								||
								(!refProcessingBegin  &&  Point.distance(primitives[ref].end, primitives[test].vectors[v].point) < Parameters.MAX_JOINT_DISTANCE)
							)
						  ) // if ()
						{
							// if TEST primitive is extension of REF primitive 
							
							primitives[ref].add(primitives[test].vectors.slice(v), PrimitiveType.isCurve(primitives[test].type));
							primitives[test].reset();
							jointProcessed = true;
							break;
							
						} 
					}
					
			
				} // end for test
				
			} // end for ref
			*/
		}

	}
}